#!/bin/bash

echo "测试堆OOM开始"

package_name='samples.java.oom.heap'
package_path='samples/java/oom/heap'
file_name="HeapOOMSamples"
file_ext="java"

java_file_name=$file_name.$file_ext
javac_file_path=$package_path/$java_file_name

echo $java_file_name
echo $javac_file_path

cd ../../../..

echo '当前路径:' `pwd`

echo "开始编译java文件: $javac_file_path"

rm -rf $package_path/*.class

javac $javac_file_path

echo "运行java程序 参数: -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError"
java -cp . -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError $package_name.HeapOOMSamples

rm -rf $package_path/*.class
